package com.rope.backEnd.controller;

import com.rope.backEnd.pojo.Result;
import com.rope.backEnd.pojo.User;
import com.rope.backEnd.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j

@RestController

public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/userListSUL")
    public Result list(){
        //记录日志
        log.info("查询全部数据");

        //调用service查询数据
        List<User> users = userService.list();

        return Result.success(users);
    }

    @PostMapping("/userSUL")
    public Result userSul(@RequestBody User username){
        //记录日志
        log.info("查询单个人数据");

        //调用service查询数据
        User users = userService.userSul(username.getName());

        return Result.success(users);
    }

}
